/*
 * BundleComparator.java
 * 
 * Created by demory on Apr 2, 2009, 10:13:54 PM
 * 
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.fpdev.apps.cart.network;

/*import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import org.fpdev.apps.cart.network.BundleComparator.LineInfo;
*/

/**
 *
 * @author demory
 */

/*
public class BundleComparator implements Comparator<LineInfo> {

  private Set<Comparison> comps_;

  public BundleComparator() {
    comps_ = new HashSet<Comparison>();
  }

  public int compare(LineInfo o1, LineInfo o2) {
    int ret = 0;
    Comparison lessThan = new Comparison(o1, o2); // assume o1 < o2
    Comparison greaterThan = new Comparison(o2, o1); // assume o1 > o2
    for(Comparison c : comps_) {
      if(c.equivalentTo(lessThan)) ret--;
      if(c.equivalentTo(greaterThan)) ret++;
    }
    return ret;
  }

  public void addComparison(LineInfo lesser, LineInfo greater) {
    comps_.add(new Comparison(lesser, greater));
  }

  public class LineInfo {
    Line line_;
    boolean fw_;
  }

  private class Comparison {
    LineInfo lesser_;
    LineInfo greater_;

    public Comparison(LineInfo lesser, LineInfo greater) {
      lesser_ = lesser;
      greater_ = greater;
    }

    public boolean equivalentTo(Comparison c) {
      if(lesser_.line_ == c.lesser_.line_ && lesser_.fw_ == c.lesser_.fw_ &&
         greater_.line_ == c.greater_.line_ && greater_.fw_ == c.greater_.fw_)
        return true;

      // A-fw < B-bw is equivalent to B-fw < A-bw
      if(lesser_.line_ == c.greater_.line_ && lesser_.fw_ == c.lesser_.fw_ &&
         greater_.line_ == c.lesser_.line_ && greater_.fw_ == c.greater_.fw_)
        return true;
      return false;
    }
  }
}
*/